// pages/my/dispatchorderdetail/dispatchorderdetail.js
Page({
  data: {
    id: "",
    bottomHeight: getApp().globalData.bottomHeight,
    dialog_show: false,
    detail: {}
  },
  onLoad: function (options) {
    this.setData({
      id: options.id
    });
    this.getData();
  },
  onShareAppMessage() {
    return {
      title: "手机兼职赚钱一单一结",
      path: '/pages/morejob/taskdestail/taskdestail?id=' + this.data.id,
    }
  },
  getData() {
    getApp().globalData.http.detail({
      id: this.data.id
    }).then(res => {
      let tmp = res.data;
      tmp.imgIds = tmp.imgIds.split(",");
      tmp.imgUrls = tmp.imgUrls.split(",");
      this.setData({
        detail: res.data
      });
    });
  },
  close() {
    this.setData({
      dialog_show: true
    });
  },
  confirm() {
    this.setData({
      dialog_show: false
    });
    getApp().globalData.http.closeTaken({
      id: this.data.id
    }).then(res => {
      getApp().globalData.vant.toast({
        type: "success",
        message: "关闭成功",
        duration: 1000,
        onClose: () => {
          wx.navigateBack();
        },
      });
    }).catch(e => {
      getApp().globalData.vant.toast.fail(e.msg);
    });
  },
  cancel() {
    this.setData({
      dialog_show: false
    });
  },
  getOrder() {
    wx.navigateTo({
      url: "/pages/my/dispatchstate/dispatchstate?id=" + this.data.detail.id,
    })
  },
  previewImg(e) {
    let arr = e.currentTarget.dataset.img;
    let current = e.currentTarget.dataset.current;
    getApp().globalData.util.previewImage(arr, current);
  }
})